<?php
    require_once('paths.inc');
    require_once('page.inc');
    require_once(INCLUDE_PATH.'constants.inc');
    require_once('utils.inc');
    
    session_start();
    
    select_language();
            
	function show_interface () {
		if (isset($_GET['index'])) $index = $_GET['index'];
			
		if (isset($index)) {
			checkIsLoggedIn();

			$ruta = $_SESSION['firma']->rute[$index];
	
			$text = LANG_Ruta_update;
			$opt = "update";	
		}
		else {
			$text = LANG_Add_Ruta; 
			$opt = "insert";
			$ruta = new RutaFirma($_SESSION['firma']->id_firma, null, null);
		}
		
		if (!isset($index)) $index = 0;
        
        $help_text = LANG_EXTRA_MODAL_ADD_RUTA;
        if ($opt == "update")
            $help_text = LANG_EXTRA_MODAL_EDIT_RUTA;
        
		$ret = '<div align=\"center\">				
					<table id="wrapper2" name="new_ruta" border="0" align="center" cellpadding=\"3\" cellspacing=\"3\">
						<thead>
							<tr>
								<th colspan="2" align="center"> ' . $text . '</th>
							</tr>
						</thead>
						<tr class="capTabel">
							<td id="td_loc1" align="right"><b>' . LANG_Loc1 . CT_OBLIGATORIU . '</b></td>
							<td align="left"><input type="text" name="rute_loc1" id="rute_loc1" value="' . $ruta->loc1 . '" size="' . CT_MODAL_ADD_RUTA_INPUT_SIZE_TEXT_BOX . '" />
						</tr>
						<tr class="capTabel">
							<td id="td_loc2" align="right"><b>' . LANG_Loc2 . CT_OBLIGATORIU . '</b></td>
							<td align="left"><input type="text" name="rute_loc1" id="rute_loc2" value="' . $ruta->loc2 . '" size="' . CT_MODAL_ADD_RUTA_INPUT_SIZE_TEXT_BOX . '" />
						</tr>
						<tr class="capTabel">
							<td colspan="2" align="center">';
				                $ret .='<input type="button" name="contact_confirm" id="contact_confirm" value="' . $text . '"' . "onclick=\"javascript: new_ruta_firma_confirm('" . $opt ."'," . $index . ");\" />&nbsp;&nbsp;";
				                $ret .='<input type="button" name="contact_cancel" id="contact_cancel" value="' . LANG_CANCEL . '" onclick="javascript: closeMessage();" />
							</td>
						</tr>'
                        . output_extra_text_modal($help_text, 2) . 
					'</table>
			</div>
			<script type="text/javascript">
				document.rute_loc1.focus();
			</script>';
			echo $ret;		
			flush();
	}
	
	show_interface();			
?>